import sys
import os
import numpy as np
import shutil
import random
import shutil


root_img = "/media/wz209/a29353b7-1090-433f-b452-b4ce827adb17/JZT/segmentation/ISIC_2018/k_folder/img"
root_mak = "/media/wz209/a29353b7-1090-433f-b452-b4ce827adb17/JZT/segmentation/ISIC_2018/k_folder/mask"


img_path = "/media/wz209/a29353b7-1090-433f-b452-b4ce827adb17/JZT/segmentation/ISIC_2018/k_folder/img/img"
mak_path = "/media/wz209/a29353b7-1090-433f-b452-b4ce827adb17/JZT/segmentation/ISIC_2018/k_folder/mask/mask"
img_list = []

img_list = sorted(os.listdir(img_path))
print(len(img_list))
print(img_list)

random.shuffle(img_list)
print(len(img_list))
print(img_list)

img_list = [x.split('.')[0] for x in img_list]
print(img_list)

for i in range(len(img_list)):
	print(i)
	img_to_path = os.path.join(root_img, "f"+str((i % 5)+1))
	mak_to_path = os.path.join(root_mak, "f"+str((i % 5)+1))

	img_from_path = os.path.join(img_path, img_list[i]+".jpg")
	mak_from_path = os.path.join(mak_path, img_list[i] + "_segmentation.png")

	# print(img_from_path)
	# print(img_to_path)
	# print(mak_from_path)
	# print(mak_to_path)
	# exit(0)
	shutil.copy(img_from_path, img_to_path)
	shutil.copy(mak_from_path, mak_to_path)

